package com.iot.device.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iot.device.mapper.BeidouClientMapper;
import com.iot.device.domain.BeidouClient;
import com.iot.device.service.IBeidouClientService;

/**
 * 海岛北斗设备Service业务层处理
 * 
 * @author iot
 * @date 2023-05-10
 */
@Service
public class BeidouClientServiceImpl implements IBeidouClientService 
{
    @Autowired
    private BeidouClientMapper beidouClientMapper;

    /**
     * 查询海岛北斗设备
     * 
     * @param id 海岛北斗设备主键
     * @return 海岛北斗设备
     */
    @Override
    public BeidouClient selectBeidouClientById(Long id)
    {
        return beidouClientMapper.selectBeidouClientById(id);
    }

    /**
     * 查询海岛北斗设备列表
     * 
     * @param beidouClient 海岛北斗设备
     * @return 海岛北斗设备
     */
    @Override
    public List<BeidouClient> selectBeidouClientList(BeidouClient beidouClient)
    {
        return beidouClientMapper.selectBeidouClientList(beidouClient);
    }

    /**
     * 新增海岛北斗设备
     * 
     * @param beidouClient 海岛北斗设备
     * @return 结果
     */
    @Override
    public int insertBeidouClient(BeidouClient beidouClient)
    {
        return beidouClientMapper.insertBeidouClient(beidouClient);
    }

    /**
     * 修改海岛北斗设备
     * 
     * @param beidouClient 海岛北斗设备
     * @return 结果
     */
    @Override
    public int updateBeidouClient(BeidouClient beidouClient)
    {
        return beidouClientMapper.updateBeidouClient(beidouClient);
    }

    /**
     * 批量删除海岛北斗设备
     * 
     * @param ids 需要删除的海岛北斗设备主键
     * @return 结果
     */
    @Override
    public int deleteBeidouClientByIds(Long[] ids)
    {
        return beidouClientMapper.deleteBeidouClientByIds(ids);
    }

    /**
     * 删除海岛北斗设备信息
     * 
     * @param id 海岛北斗设备主键
     * @return 结果
     */
    @Override
    public int deleteBeidouClientById(Long id)
    {
        return beidouClientMapper.deleteBeidouClientById(id);
    }

    @Override
    public BeidouClient selectBeidouClientByClientNo(String clientNo) {
        return beidouClientMapper.selectBeidouClientByClientNo(clientNo);
    }

    @Override
    public Map<String, Long> selectBeidouClientStatistics(Long userId) {
        Map<String, Long> map = beidouClientMapper.selectBeidouClientStatistics(userId);
        if(map == null){
            map = new HashMap<>();
            map.put("onlineCount", 0L);
            map.put("totalCount", 0L);
        }
        return map;
    }

    @Override
    public Map<String, Long> countBeidouClientsByUserId(Long userId) {
        return beidouClientMapper.countBeidouClientsByUserId(userId);
    }
}
